<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>quapro</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>Scilab Function</center>
    <div align="right">Last update : 29/06/2005</div>
    <p>
      <b>quapro</b> -  linear quadratic programming solver</p>
    <h3>
      <font color="blue">Calling Sequence</font>
    </h3>
    <dl>
      <dd>
        <tt>[x,lagr,f]=quapro(Q,p,C,b [,x0])  </tt>
      </dd>
      <dd>
        <tt>[x,lagr,f]=quapro(Q,p,C,b,ci,cs [,x0])  </tt>
      </dd>
      <dd>
        <tt>[x,lagr,f]=quapro(Q,p,C,b,ci,cs,me [,x0])  </tt>
      </dd>
      <dd>
        <tt>[x,lagr,f]=quapro(Q,p,C,b,ci,cs,me,x0 [,imp])  </tt>
      </dd>
    </dl>
    <h3>
      <font color="blue">Parameters</font>
    </h3>
    <ul>
      <li>
        <tt>
          <b>Q</b>
        </tt>: real symmetric matrix (dimension <tt>
          <b>n x n</b>
        </tt>).</li>
      <li>
        <tt>
          <b>p</b>
        </tt>: real (column) vector (dimension <tt>
          <b> n</b>
        </tt>)</li>
      <li>
        <tt>
          <b>C</b>
        </tt>: real matrix (dimension <tt>
          <b> (me + md) x n</b>
        </tt>) (If no
	    constraints are given, you can set <tt>
          <b>C = []</b>
        </tt>)</li>
      <li>
        <tt>
          <b>b</b>
        </tt>: RHS column vector (dimension <tt>
          <b> (me + md)</b>
        </tt>) (If no
	    constraints are given, you can set <tt>
          <b>b = []</b>
        </tt>)</li>
      <li>
        <tt>
          <b>ci</b>
        </tt>: column vector of lower-bounds (dimension <tt>
          <b>n</b>
        </tt>). If
	    there are no lower bound constraints, put <tt>
          <b>ci = []</b>
        </tt>. If
	    some components of <tt>
          <b>x</b>
        </tt> are bounded from below, set the
	    other (unconstrained) values of <tt>
          <b>ci</b>
        </tt> to a very  large
	    negative  number (e.g. <tt>
          <b>ci(j) =
	      -number_properties('huge')</b>
        </tt>.</li>
      <li>
        <tt>
          <b>cs</b>
        </tt>: column vector of upper-bounds. (Same remarks as above).</li>
      <li>
        <tt>
          <b>me</b>
        </tt>: number of equality constraints (i.e. <tt>
          <b>C(1:me,:)*x = b(1:me)</b>
        </tt>)</li>
      <li>
        <tt>
          <b>x0</b>
        </tt>: either an initial guess for <tt>
          <b>x</b>
        </tt>    or one of the
	    character strings <tt>
          <b>'v'</b>
        </tt> or <tt>
          <b>'g'</b>
        </tt>. If
	    <tt>
          <b>x0='v'</b>
        </tt> the calculated initial feasible point is a
	    vertex. If <tt>
          <b>x0='g'</b>
        </tt> the calculated initial feasible
	    point is arbitrary.</li>
      <li>
        <tt>
          <b>imp</b>
        </tt>: verbose option (optional parameter)   (Try
	    <tt>
          <b>imp=7,8,...</b>
        </tt>). warning the message are output in the
	    window where scilab has been started.</li>
      <li>
        <tt>
          <b>x</b>
        </tt>: optimal solution found.</li>
      <li>
        <tt>
          <b>f</b>
        </tt>: optimal value of the cost function (i.e. <tt>
          <b>f=0.5*x'*Q*x+p'</b>
        </tt>).</li>
      <li>
        <tt>
          <b>lagr</b>
        </tt>: vector of Lagrange multipliers.  If lower and upper-bounds
	    <tt>
          <b>ci,cs</b>
        </tt> are provided, <tt>
          <b>lagr</b>
        </tt> has  <tt>
          <b>n +
	      me + md</b>
        </tt> components and <tt>
          <b>lagr(1:n)</b>
        </tt> is the
	    Lagrange  vector associated with the bound constraints and
	    <tt>
          <b>lagr (n+1 : n + me + md)</b>
        </tt> is the Lagrange vector
	    associated  with the linear constraints. (If an upper-bound
	    (resp. lower-bound) constraint <tt>
          <b>i</b>
        </tt> is active
	    <tt>
          <b>lagr(i)</b>
        </tt> is &gt; 0 (resp. &lt;0). If no bounds are
	    provided, <tt>
          <b>lagr</b>
        </tt> has only <tt>
          <b>me + md</b>
        </tt>
	    components.</li>
    </ul>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>
    Minimize <tt>
        <b>0.5*x'*Q*x + p'*x</b>
      </tt>
    </p>
    <p>
    under the constraint</p>
    <pre>

C*x &lt;= b
   
    </pre>
    <p>
    Minimize <tt>
        <b> 0.5*x'*Q*x + p'*x</b>
      </tt>
    </p>
    <p>
    under the constraints</p>
    <pre>

C*x &lt;= b          ci &lt;= x &lt;= cs
   
    </pre>
    <p>
    Minimize <tt>
        <b> 0.5*x'*Q*x + p'*x</b>
      </tt>
    </p>
    <p>
    under the constraints</p>
    <pre>

 C(j,:) x = b(j),  j=1,...,me
 C(j,:) x &lt;= b(j), j=me+1,...,me+md
 ci &lt;= x &lt;= cs
   
    </pre>
    <p>
    If no initial point is given the
    program computes a feasible initial point
    which is a vertex of the region of feasible points if
    <tt>
        <b>x0='v'</b>
      </tt>.</p>
    <p>
    If <tt>
        <b>x0='g'</b>
      </tt>, the program computes a feasible initial 
    point which is not necessarily a vertex. This mode is
    advisable when the quadratic form is positive
    definite and there are  few constraints in
    the problem or when there are large bounds
    on the variables that are just security bounds and
    very likely not active at the optimal solution.</p>
    <p>
    Note that <tt>
        <b>Q</b>
      </tt> is not necessarily non-negative, i.e.
    <tt>
        <b>Q</b>
      </tt> may have negative eigenvalues.</p>
    <h3>
      <font color="blue">Examples</font>
    </h3>
    <pre>

//Find x in R^6 such that:
//C1*x = b1 (3 equality constraints i.e me=3)
C1= [1,-1,1,0,3,1;
    -1,0,-3,-4,5,6;
     2,5,3,0,1,0];
b1=[1;2;3];
//C2*x &lt;= b2 (2 inequality constraints)
C2=[0,1,0,1,2,-1;
    -1,0,2,1,1,0];
b2=[-1;2.5];
//with  x between ci and cs:
ci=[-1000;-10000;0;-1000;-1000;-1000];cs=[10000;100;1.5;100;100;1000];
//and minimize 0.5*x'*Q*x + p'*x with
p=[1;2;3;4;5;6]; Q=eye(6,6);
//No initial point is given;
C=[C1;C2] ; //
b=[b1;b2] ;  //
me=3;
[x,lagr,f]=quapro(Q,p,C,b,ci,cs,me)
//Only linear constraints (1 to 4) are active (lagr(1:6)=0):
[x,lagr,f]=quapro(Q,p,C,b,[],[],me)   //Same result as above
 
  </pre>
    <h3>
      <font color="blue">See Also</font>
    </h3>
    <p>
      <a href="qld.htm">
        <tt>
          <b>qld</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="linpro.htm">
        <tt>
          <b>linpro</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="optim.htm">
        <tt>
          <b>optim</b>
        </tt>
      </a>,&nbsp;&nbsp;</p>
    <h3>
      <font color="blue">Authors</font>
    </h3>
    <dl>
      <dd>
        <b>Eduardo Casas  Renteria</b>, Universidad de Cantabria,</dd>
      <dd>
        <b>Cecilia Pola Mendez</b> , Universidad de Cantabria</dd>
    </dl>
    <h3>
      <font color="blue">Used Function</font>
    </h3>
    <p>
in routines/optim directory (authors E.Casas, C. Pola Mendez):</p>
    <p>
anfm01.f  anfm03.f  anfm05.f  anrs01.f  auxo01.f  dimp03.f  dnrm0.f   optr03.f  pasr03.f  zthz.f
anfm02.f  anfm04.f  anfm06.f  anrs02.f  desr03.f  dipvtf.f  optr01.f
opvf03.f  plcbas.f</p>
    <p> From BLAS library</p>
    <p>
daxpy.f dcopy.f ddot.f dnrm2.f dscal.f dswap.f idamax.f</p>
    <p> in routines/calelm directory (authors INRIA):</p>
    <p>
add.f ddif.f dmmul.f</p>
    <p> From LAPACK library : dlamch.f</p>
  </body>
</html>
